<template>
  <dt-modal-edit ref="edit" title="请选择需分入线索的人员" :width="500" :loading="loading" @ok="onOk">
    <div>
      <p style="margin-bottom: 10px;">分配线索后，勾选线索可在分配人员的未到访客户列表查看该线索信息</p>

      <dt-grid ref="table" :columns="columns" :onFetch="onFetch" :height="400" />
    </div>
  </dt-modal-edit>
</template>

<script>
  import columnOpt from '../opt/allotColumn.js'
  import clueCustomerMgr from '@/biz/customer/clueCustomer.js'

  export default {
    data() {
      return {
        columns: [],
        selected: null,
        loading: false,
        userCustomerIds: null
      }
    },
    methods: {
      onOk() {
        if (!this.selected) {
          this.$Message.error('请选择需分入线索的人员')
          return
        }
        this.loading = true
        clueCustomerMgr.distribution({
          type: 0, // 0: 单选或多选   1: 全选
          userCustomerIds: this.userCustomerIds,
          userId: this.selected
        }).then(res => {
          this.$Message.success('分配成功')
          this.$parent.$refs.table.fetch()
          this.$parent.selected = []
          this.loading = false
          this.hide()
        }).catch(() => {
          this.loading = false
        })
      },
      onFetch(data) {
        let params = { onlineType: 1 }
        // return clueCustomerMgr.adviserList({ params })

        return clueCustomerMgr.adviserList(params).then((res) => {
          return res
        })


      },
      show(info) {
        console.log('aaaaaaaaaaaaaa');
        this.selected = null
        this.userCustomerIds = info
        this.$refs.edit.show()
        this.columns = columnOpt.options(this)
        this.$refs.table.init(this)
        this.$refs.table.fetch()
      },
      hide() {
        this.$refs.edit.hide()
      },
    }
  }
</script>

<style lang="scss" scoped>
</style>